package implentation;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import org.esiag.isidis.AbstractThread;
import org.esiag.isidis.PoolThreadManager;

import rmi.InvokeRMI;

public class Invoker    implements InvokeRMI {
	
	
	private AbstractThread thread;

	public Invoker() throws RemoteException {
		
			
			
	}
	
	

	@Override
	public Object Invoke(String classe, String methode, Object[] arguments)
			throws RemoteException {
		System.out.println(classe+" :etape 1");
		ConcreteThread thread = new ConcreteThread(classe+methode, classe, methode, arguments);
		try {
			PoolThreadManager.getInstance().addAndStartThread(thread);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return thread.getResultat();
		
		
	}

		

	public String[] getApplications() throws RemoteException {
		// TODO Auto-generated method stub
		System.out.println("f");
		String[] tab=  new String[5];
		int i = 0;
		for (String s :new java.io.File("jar").list( )) {
			if (s.subSequence(s.length()-3, s.length()) == "jar") {
				tab[i++]=s;
				
			}
			
			
		}
		return  new java.io.File("jar").list( );
	}



	public Class<?> Avalaible() throws RemoteException {
		// TODO Auto-generated method stub
		return null;
	}

}
